#include "myblock.h"
#include <QTime>

int dataBase[7][4];

MyBlock::MyBlock()
{
    int temp[] =
    {
        1, 3, 5, 7, // I型
        2, 4, 5, 7, // Z1型
        3, 5, 4, 6, // Z2型
        3, 5, 4, 7, // T型
        2, 3, 5, 7, // L型
        3, 5, 7, 6, // J型
        2, 3, 4, 5, // 田型
    };
    memcpy(this->dataBase, temp, sizeof(temp));

}

void MyBlock::newBlock()
{
    /* 生成0-6随机数 */
    qsrand(QTime(0,0,0).msecsTo(QTime::currentTime()));
    int num = qrand() % 7;
    this->blocksColor = num + 1;

    for(int i = 0; i < 4; i++)
    {
        this->curBlockArr[i].x = this->dataBase[num][i] % 2;
        this->curBlockArr[i].y = this->dataBase[num][i] / 2;
        this->curBlockArr[i].dropping = 1;
    }

}
